home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE22 / CLINIC / MemoTextMainForm.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-04-06  |  1.3 KB  |  55 lines

  1. unit MemoTextMainForm;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Memo1: TMemo;
  12.     Label1: TLabel;
  13.     procedure Memo1DragOver(Sender, Source: TObject; X, Y: Integer;
  14.       State: TDragState; var Accept: Boolean);
  15.     procedure Memo1DragDrop(Sender, Source: TObject; X, Y: Integer);
  16.   private
  17.     { Private declarations }
  18.   public
  19.     { Public declarations }
  20.   end;
  21.  
  22. var
  23.   Form1: TForm1;
  24.  
  25. implementation
  26.  
  27. {$R *.DFM}
  28.  
  29. procedure TForm1.Memo1DragOver(Sender, Source: TObject; X, Y: Integer;
  30.   State: TDragState; var Accept: Boolean);
  31. begin
  32.   { Allow edit -> memo drag & drop }
  33.   Accept := Source is TLabel
  34. end;
  35.  
  36. procedure TForm1.Memo1DragDrop(Sender, Source: TObject; X, Y: Integer);
  37. var
  38.   Pt: TSmallPoint;
  39. begin
  40.   with Sender as TMemo do
  41.   begin
  42.     { Turn co-ordinates into a TSmallPoint }
  43.     Pt := PointToSmallPoint(Point(X, Y));
  44.     { Do a down click }
  45.     Perform(wm_LButtonDown, 0, Longint(Pt));
  46.     { Do an up click }
  47.     Perform(wm_LButtonUp, 0, Longint(Pt));
  48.     { The memo's input caret is now nicely poised }
  49.     { Insert the edit's selected text into the memo }
  50.     SelText := (Source as TLabel).Caption
  51.   end
  52. end;
  53.  
  54. end.
  55.